<HTML> 
<HEAD> 
	<TITLE>3rd Party ROBOTC Drivers</TITLE> 
<link href="tabs.css" rel="stylesheet" type="text/css"/> 
<link href="doxygen.css" rel="stylesheet" type="text/css"/> 
</HEAD> 
 
<BODY bgcolor="#ffffff" link="#000000" vlink="#000000"> 
<table width="100%" bgcolor="navy" cellspacing=0 cellpadding=1 border=0> 
<tr><td><table width="100%" bgcolor="#EEEEDD" cellspacing=0 cellpadding=3 border=0> 
<tr> 
    <td width="33%" align="left"> <img src="images/LOGO_NXT.gif" width=266 height=44 border="0" alt="Mindstorms"></td> 
    <td><b><font size="+3" color="navy">3rd Party ROBOTC Drivers</font></b></td> 
    <td align="right"> <img src="images/logo.png" width=44 height=44 border="0" alt="RobotC"></td>     
</tr> 
  <tr bgcolor="#cccc99" align="right"> 
          <td colspan=3> <font face="arial" size="-1"> [<a href=main.html>Home</a>] [<a target=_top href="https://sourceforge.net/projects/rdpartyrobotcdr/">Download</a>] [<a target=_top href="http://apps.sourceforge.net/mantisbt/rdpartyrobotcdr/my_view_page.php">Submit a bug/suggestion</a>]  [<a target=_top href="http://www.robotc.net/forums/">ROBOTC Forums</a>] [<a target=_top href="http://botbench.com">Blog</a>] [<a target=_top href="http://sourceforge.net/donate/index.php?group_id=257238">Support this project</a>]</font> </td> 
</tr> 
</table></td></tr> 
</table> 
<!-- Generated by Doxygen 1.7.2 -->
<div class="header">
  <div class="headertitle">
<h1>dexterind-nxtchuck-test1.c</h1>  </div>
</div>
<div class="contents">
<div class="fragment"><pre class="fragment"><span class="preprocessor">#pragma config(Sensor, S1,     CHUCKNORRIS,    sensorI2CCustom)</span>
<span class="preprocessor"></span><span class="comment">//*!!Code automatically generated by &#39;ROBOTC&#39; configuration wizard               !!*//</span>

<span class="comment">/*</span>
<span class="comment"> * $Id: dexterind-nxtchuck-test1.c 133 2013-03-10 15:15:38Z xander $</span>
<span class="comment"> */</span>
<span class="comment"></span>
<span class="comment">/**</span>
<span class="comment"> * dexterind-nxtchuck.h provides an API for the Dexter Industries NXTChuck sensor.</span>
<span class="comment"> * This program demonstrates how to use that API.</span>
<span class="comment"> *</span>
<span class="comment"> * Changelog:</span>
<span class="comment"> * - 0.1: Initial release</span>
<span class="comment"> *</span>
<span class="comment"> * Credits:</span>
<span class="comment"> * - Big thanks to Matthew Richardson and Dexter Industries for providing me with the</span>
<span class="comment"> * hardware necessary to write and test this.</span>
<span class="comment"> *</span>
<span class="comment"> * License: You may use this code as you wish, provided you give credit where it&#39;s due.</span>
<span class="comment"> *</span>
<span class="comment"> * THIS CODE WILL ONLY WORK WITH ROBOTC VERSION 3.59 AND HIGHER. </span>
<span class="comment"></span>
<span class="comment"> * Xander Soldaat (xander_at_botbench.com)</span>
<span class="comment"> * 31 October 2012</span>
<span class="comment"> * version 0.1</span>
<span class="comment"> */</span>

<span class="preprocessor">#include &quot;<a class="code" href="dexterind-nxtchuck_8h.html" title="Dexter Industries NXTChuck Sensor driver.">drivers/dexterind-nxtchuck.h</a>&quot;</span>

task main()
{

  <a name="_a0"></a><a class="code" href="structt_nunchuck.html">tNunchuck</a> chucky;

  byte Device = 0;
  <a name="a1"></a><a class="code" href="group___n_x_t_c_h_u_c_k.html#ga7e7456a1ff24dfebe5e3fde04cc2fa71">NXTChuckreadIdent</a>(CHUCKNORRIS, chucky);
  writeDebugStreamLine(<span class="stringliteral">&quot;dev: %d&quot;</span>, Device);

  <span class="keywordflow">while</span> (<span class="keyword">true</span>)
  {
    <span class="comment">//if(Device == NXTCHUCK_DEVICE_NUNCHUK){                                          // If it identified the extension as a Nunchuk</span>
      <span class="keywordflow">if</span> (<a name="a2"></a><a class="code" href="group___n_x_t_c_h_u_c_k.html#ga763586a19d4de3dcd3e74c43ec15f82d">NXTChuckreadSensor</a>(S1, chucky)) {      <span class="comment">// Read the Nunchuk</span>


        nxtDisplayTextLine(0, <span class="stringliteral">&quot;Stick  X  %d&quot;</span>, chucky.<a name="a3"></a><a class="code" href="structt_nunchuck.html#aec86757fae7769579f06ae433a0a5d44">stickX</a>);
        nxtDisplayTextLine(1, <span class="stringliteral">&quot;Stick  Y  %d&quot;</span>, chucky.<a name="a4"></a><a class="code" href="structt_nunchuck.html#a91804e03b8050dbb60a0097eda903f57">stickY</a>);
        nxtDisplayTextLine(2, <span class="stringliteral">&quot;Accel  X  %d&quot;</span>, chucky.<a name="a5"></a><a class="code" href="structt_nunchuck.html#aeb96883d9be554e3130dd8a074dd1181">accelX</a>);
        nxtDisplayTextLine(3, <span class="stringliteral">&quot;Accel  Y  %d&quot;</span>, chucky.<a name="a6"></a><a class="code" href="structt_nunchuck.html#aa79b1c1093bc17ca66f39fa286fb8c16">accelY</a>);
        nxtDisplayTextLine(4, <span class="stringliteral">&quot;Accel  Z  %d&quot;</span>, chucky.<a name="a7"></a><a class="code" href="structt_nunchuck.html#ac1d83c37ada1e57ee781a2e8eea0472a">accelZ</a>);
        nxtDisplayTextLine(5, <span class="stringliteral">&quot;Button C  %d&quot;</span>, chucky.<a name="a8"></a><a class="code" href="structt_nunchuck.html#a739999c8e3c48d0a6a60783b778c4a6b">buttonC</a>);
        nxtDisplayTextLine(6, <span class="stringliteral">&quot;Button Z  %d&quot;</span>, chucky.<a name="a9"></a><a class="code" href="structt_nunchuck.html#ad21c5419fe7bae1473d6b2a153a89a2e">buttonZ</a>);
        nxtDisplayTextLine(7, <span class="stringliteral">&quot;Buttons   %d&quot;</span>, chucky.<a name="a10"></a><a class="code" href="structt_nunchuck.html#acfe810cf5fd316d47ead62fa49987852">buttons</a>);
      }
      <span class="keywordflow">else</span> {
        wait1Msec(100);
        eraseDisplay();
        nxtDisplayTextLine(0, <span class="stringliteral">&quot;Failed&quot;</span>);
      }
    <span class="comment">//}</span>
    wait1Msec(10);
  }
}
</pre></div> </div>
</div>
<hr class="footer"/><address class="footer"><small>Generated on Wed Mar 13 2013 19:56:41 for ROBOTC Drivers by&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.2 </small></address>
</body>
</html>
